import logging
from redis import StrictRedis


class Config(object):
    "配置文件"
    SECRET_KEY = 'FDASKHFKHG46374387592347RP48T7GHS897gfgshlkfsdfg'
    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information27"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # ｒｅｄｉｓ的配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # session 配置
    SESSION_TYPE = 'redis'
    # 开启ｓｅｓｓｉｏｎ　签名
    SESSION_USE_SIGNER = True
    # 制定ｓｅｓｓｉｏｎ保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 设置需要过期
    SESSION_PERMANENT = False
    #　设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2
    # 日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True

class ProductionConfig(Config):
    """生产环境"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING

class TestingConfig(Config):
    """单元测试配置"""
    DEBUG = True
    TETSTING = True

config = {
    "development" :DevelopmentConfig,
    "production": ProductionConfig,
    "testing":TestingConfig,
}